package com.zuser.project.controller;

import com.zuser.project.entity.ProfitsharingRuleEntity;
import com.zuser.project.service.ProfitsharingRuleService;
import com.zuser.project.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 分账规则表
 *
 * @author zuser
 * @email 2076033693@gmail.com
 * @date 2025-04-21 10:51:03
 */
@RestController
@RequestMapping("generator/profitsharingrule")
public class ProfitsharingRuleController {
    @Autowired
    private ProfitsharingRuleService profitsharingRuleService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){

        return profitsharingRuleService.queryPage(params);
    }



    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		ProfitsharingRuleEntity profitsharingRule = profitsharingRuleService.getById(id);

        return R.ok().put("profitsharingRule", profitsharingRule);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody ProfitsharingRuleEntity profitsharingRule){
		profitsharingRuleService.save(profitsharingRule);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody ProfitsharingRuleEntity profitsharingRule){
		profitsharingRuleService.updateById(profitsharingRule);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		profitsharingRuleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
